package exception;

public class FinallyDemo {
    public static void main(String[] args) {
        System.out.println("程序开始");
        try{
            String str = "abcd";
            //String str = null;
            System.out.println(str.length());
            //就算return也会走finally
        //return;
        }
        catch (NullPointerException e){
            System.out.println("触发了空指针异常");
        }
        finally {
            System.out.println("finally块必定执行");
        }
        System.out.println("程序结束了");
    }
}
